""" -*- mode: python; coding: utf-8; -*-

    Copyright 2008 Asier Aguirre <asier.aguirre@gmail.com>
    This file is part of Intromit.

    Intromit is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Intromit is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Intromit.  If not, see <http://www.gnu.org/licenses/>.
"""

import sys, python_config, pyintromit, unittest, python_runner
pyintromit.load("intromit/test/.libs/libpython_basic.so")
import libpython_basic

class test_1_basic(unittest.TestCase):

    def test_1(self):
        "Checks package existence"
        self.failUnless("libpython_basic" in globals().keys(), "No libpython_basic package")

    def test_2(self):
        "Checks class existence in package"
        self.failUnless("python_basic" in dir(libpython_basic), "No python_basic class in module")

    def test_3(self):
        "Checks existence of method function"
        self.failUnless("its_working" in dir(libpython_basic.python_basic), "No its_working method in class python_basic")

    def test_4(self):
        "Test a method with 2 integer params and returns its sum"
        basic=libpython_basic.python_basic()
        self.assertEqual(basic.its_working(2, 2), 4, "Call to function and check result")


if __name__ == '__main__':

    suite = unittest.TestLoader().loadTestsFromTestCase(test_1_basic)
    result=python_runner.BasicTestRunner(iterations=len(sys.argv)>1 and sys.argv[1] or 1,
	stream=len(sys.argv)>2 and open(sys.argv[2], "w") or sys.stderr).run(suite)
    sys.exit(not result.wasSuccessful())
